package cn.javaxxw.springboot;

import cn.org.atool.generator.FileGenerator;
import cn.org.atool.generator.annotation.Table;
import cn.org.atool.generator.annotation.Tables;
import org.junit.jupiter.api.Test;
/**
 * 功能描述: 
 * @author  TuYong
 * @date  2022/9/19 15:39
 */
public class EntityGenerator {

    /**
     * 数据源url
     */
    static final String URL = "jdbc:mysql://172.17.24.11:3306/springboot_demo?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&autoReconnect=true";

    /**
     * 数据库用户名
     */
    static final String USERNAME = "root";

    /**
     * 数据库密码
     */
    static final String PASSWORD = "123456";

    @Test
    public void generate() throws Exception {
        //引用配置类，build方法允许有多个配置类
        FileGenerator.build(Empty.class);
    }

    @Tables(
            //设置数据库连接信息
            url = URL,username = USERNAME,password = PASSWORD,
            //设置entity类生成src目录，相对于user.dir
            srcDir = "src/main/java",
            //设置entity类的package值
            basePack = "cn.javaxxw.springboot",
            //设置dao接口和实现的src目录，相对于user.dir
            daoDir = "src/main/java",
            tablePrefix = "t_",
            //设置哪些表要生成Entity文件
            tables = {@Table(value = "t_user")}
    )
    static class Empty{ //类名随便取，只是配置定义的一个载体

    }

}
